package snafu.implementation.states.literals.surround;

import snafu.framework.objects.WorldObject;
import snafu.framework.states.literals.StateLiteralItself;
import snafu.framework.states.literals.StateLiteralView;
import snafu.framework.view.Access;

public class SurroundLiteralItself extends StateLiteralItself<WorldObject> implements SurroundLiteral {

	private int range;
	
	/**
	 * Initiates a new literal with an object and a range.
	 * 
	 * @param value
	 *            the object that surrounds the world object
	 * @param range
	 *            the range indicating how far the object surrounds the world object
	 * @param privacy
	 *            the access type
	 */
	public SurroundLiteralItself(WorldObject value, int range, Access privacy) {
		super(value, privacy);
		this.range = range < 0 ? 0 : range;
	}
	
	/**
	 * Same as above but sets the range value to 0.
	 * 
	 * @param value
	 *            the object that surrounds the world object
	 * @param privacy
	 *            the access type
	 */
	public SurroundLiteralItself(WorldObject value, Access privacy) {
		this(value, 0, privacy);
	}

	@Override
	public StateLiteralView<WorldObject> createView(Access access) {
		return new SurroundLiteralView(access, this);
	}
	
	@Override
	public int getRange() {
		return range;
	}

}
